package com.flyco.config;

import com.flyco.modules.oms.service.IOmsOrderService;
import com.flyco.modules.task.service.SapTaskService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;

@Configuration      //1.主要用于标记配置类，兼备Component的效果。
@EnableScheduling   // 2.开启定时任务
@Slf4j
public class SaticScheduleTask {

    @Resource
    private SapTaskService sapTaskService;
    @Resource
    private IOmsOrderService omsOrderService;
    //每秒进行待支付订单的查询，只查询5分钟之内的订单
 // @Scheduled(cron = "*/2 * * * * ?")
    private void updateStockTask() throws Exception {
        omsOrderService.updatePayOrderStatus();
    }
   // @Scheduled(cron = "*/1 * * * * ?")
    private void updateStockTaskRedis() throws Exception {
        omsOrderService.updateOutStockStatusRedis();
    }

    /*使用接口的方式替代
    //添加7点到22点 每半小时更新一次商品库存
    @Scheduled(cron = "0 0/3 07-22 * * ?")
    private void updateStockTask() {
        sapTaskService.toSapStock();
    }

    //添加7点到22点 每15分钟给物流提货订单发送消息
    @Scheduled(cron = "0 0/15 07-22 * * ?")
    private void sendPickupMsg() {
        omsOrderService.sendPickupMsg();
    }

    //添加7点到22点每120分钟获取经销商余额
    @Scheduled(cron = "0 0/3 07-22 * * ?")
    public void updateBalance() {
        sapTaskService.updateBalance("");
    }


    //添加7点到22点每120分钟获取经销商可售和价格
    @Scheduled(cron = "0 0/120 07-22 * * ?")
    private void getProductPrice() {
        sapTaskService.getSapProductPrice("");
    }

    //添加7点到22点每120分钟获取经销商对账单
    @Scheduled(cron = "0 0/30 07-22 * * ?")
    private void pushOrderToSap() {
        sapTaskService.pushOrderToSap();
    }*/
}
